// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Title Card Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// Aliases
private alias object.value0 : object.timer
private alias object.value1 : text.timer
private alias object.value2 : text.appear

private alias 0 : CUTSCENE_NONE
private alias 1 : CUTSCENE_MIDZONE
private alias 2 : CUTSCENE_ENDZONE
private alias 666 : GROUP_CUTSCENES

// Static Values
public value TitleCard_value23 = 0;

// Player Aliases
private alias object.controlMode : player.controlMode
private alias object.jumpPress 	 : player.jumpPress
private alias object.jumpHold 	 : player.jumpHold
private alias object.up 		 : player.up
private alias object.down 		 : player.down
private alias object.left 		 : player.left
private alias object.right 		 : player.right
private alias object.value1 	 : player.timer

// Determines whether the act results will say got through zone or got through act [num]
private alias TitleCard_value23 : TitleCard_showZoneText

event ObjectMain

	options.touchControls = false

	if options.gamemode == 1
		player[currentPlayer].controlMode = -1
	end if
	
	switch object.state
	case 0
		stage.pauseEnabled = 0
		object.frame = 62
		object.alpha  = 0
		object.value3 = -216
		object.value4 = 516
		object.value5 = 0

		object.state++

		break
	case 1
		if object.value3 <= 70
			object.value3 += 8
		else
			object.state++
		end if
		break
	case 2
		HUD.hidden = 0
		object.rotation += 4
		if text.timer <= 390
			text.timer++
		else
			PlaySfx(SfxName[Boss Subtitle], 0)
			object.state ++
		end if
		break

	case 3
		if object.value4 >= 280
			object.value4 -= 10
		else
			object.value4 -= 1
			object.timer++
			if object.timer == 100
				object.state++
			end if
		end if		
		break

	case 4
		object.value4 -= 1
		object.rotation += 10
		object.priority = PRIORITY_ACTIVE
		if object.value3 >= -216
			object.value3 -= 32
			object.value5 += 10
			object.value4 -= 40
		else
			object.state++
		end if
		break

	case 5
		if object.timer < 48
			object.timer++
		else
			object.timer = 0
			object.state++
		end if
		break
	case 6
		object.value1 -= 32
		object.value2 -= 32
		object.value8 += 32
		if object.timer < 5
			object.timer++
		else	
			stage.timeEnabled = true
			stage.pauseEnabled = 1
			object.timer = 0
			object.type = TypeName[Blank Object]
		end if
		break

	end switch
end event


event ObjectDraw
	Object.inkEffect = INK_ALPHA	
	
		temp1 = 25
		temp0 = 100
		temp2 = 30
		temp4 = object.value5
		temp4 += 205
		text.appear = 20
		SetActivePalette(0, 0, screen.ysize)
		DrawSpriteScreenFX(26, FX_ROTATE, object.value3, 155)
		DrawSpriteScreenXY(27, object.value3, 103)

		if text.timer >= text.appear
			DrawSpriteScreenXY(18, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 += 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(14, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 -= 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(20, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 += 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(11, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 -= 5
		text.appear += temp2
		temp0 += temp1
		temp0 += 10

		if text.timer >= text.appear
			DrawSpriteScreenXY(14, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 += 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(2, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 -= 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(19, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 += 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(14, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 -= 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(15, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 += 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(14, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 -= 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(8, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if
		temp4 += 5
		text.appear += temp2
		temp0 += temp1

		if text.timer >= text.appear
			DrawSpriteScreenXY(3, temp0, temp4)
		end if
		if text.timer == text.appear
			PlaySfx(SfxName[Boss Name Reveal], 0)
		end if

		temp4 = object.value5
		temp4 += 180
		DrawSpriteScreenXY(28, object.value4, 180)
end event

event ObjectStartup

	LoadSpriteSheet("Global/BossCard.gif")


	// Title card frames
	SpriteFrame(0, 0, 28, 19, 134, 4)			//00	A
	SpriteFrame(0, 0, 28, 19, 166, 4)			//01	B
	SpriteFrame(0, 0, 28, 19, 198, 4)			//02	C
	SpriteFrame(0, 0, 28, 19, 230, 4)			//03	D
	SpriteFrame(0, 0, 28, 19, 262, 4)			//04	E
	SpriteFrame(0, 0, 28, 19, 294, 4)			//05	F
	SpriteFrame(0, 0, 28, 19, 326, 4)			//06	G
	SpriteFrame(0, 0, 28, 19, 361, 4)			//07	H
	SpriteFrame(4, 0, 25, 19, 390, 4)			//08	I
	SpriteFrame(0, 0, 28, 19, 422, 4)			//09	J
	SpriteFrame(0, 0, 28, 19, 447, 4)			//10	K
	SpriteFrame(0, 0, 28, 19, 134, 33)			//11	L
	SpriteFrame(0, 0, 28, 19, 166, 33)			//12	M
	SpriteFrame(0, 0, 28, 19, 198, 33)			//13	N
	SpriteFrame(0, 0, 28, 19, 231, 33)			//14	O
	SpriteFrame(0, 0, 28, 19, 262, 33)			//15	P
	SpriteFrame(0, 0, 28, 19, 294, 33)			//16	Q
	SpriteFrame(0, 0, 28, 19, 326, 33)			//17	R
	SpriteFrame(0, 0, 28, 19, 361, 33)			//18	S
	SpriteFrame(0, 0, 28, 19, 394, 33)			//19	T
	SpriteFrame(2, 0, 28, 19, 426, 33)			//20	U
	SpriteFrame(0, 0, 28, 19, 447, 4)			//21	V
	SpriteFrame(0, 0, 28, 19, 134, 4)			//22	W
	SpriteFrame(0, 0, 28, 19, 134, 4)			//23	X
	SpriteFrame(0, 0, 28, 19, 134, 4)			//24	Y
	SpriteFrame(0, 0, 28, 19, 134, 4)			//25	Z

	SpriteFrame(-65,-73, 130, 145, 1,1)			//26 Main
	SpriteFrame(-65, -22, 130, 145, 1,147)			//27 Main 2

	//Boss Names
	SpriteFrame(0, 0, 162, 13, 132, 84)			//28 SG





	if options.vsMode == true
		CallNativeFunction2(ReceiveEntity, 0x400, 1)
		ResetObjectEntity(0x400, TypeName[Blank Object], 0, 0, 0)
	end if

	// Cycle through all Title Card objects
	arrayPos0 = 32
	while arrayPos0 < 0x420
		if object[arrayPos0].type == TypeName[Boss Title Card]
			HUD.hidden = 1
			object[arrayPos0].priority 	= PRIORITY_INACTIVE
			object[arrayPos0].alpha 	= 0xFF
			object[arrayPos0].drawOrder = 6
		end if

		arrayPos0++
	loop
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
